package com.dsx.controller;


import com.dsx.commons.result.Result;
import com.dsx.entity.User;
import com.dsx.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dsx
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;
    
    //测试项目能否正常运行 ，访问  http://localhost:9999/user/1
    @RequestMapping("/{id}")
    public Result getUser(@PathVariable("id") Long id){
        User user = userService.getById(id);
        return Result.success(user);
        
    } 
    @PostMapping("/save")
    public Result saveUser(@Validated User user){
        
        return Result.success(user);
    }
    @PostMapping("/save2")
    public Result saveUser2(User user){
        
        return Result.success(user);
    }
}
